import moment from 'moment'

const func = {

    gridDateFormat: function(row, column) {
        let data = row[column.property];
        if (data == null) {
            return '';
        }
        let date = new Date(data);
        return moment(date).format('YYYY-MM-DD');
    },

    gridDatetimeFormat: function(row, column) {
        let data = row[column.property];
        if (data == null) {
            return '';
        }
        let date = new Date(data);
        return moment(date).format('YYYY-MM-DD HH:mm:ss');
    },

    timeChange: function(time) {
        if (time !== null && time !== '') {
            let date = new Date(time);
            return moment(date).format('YYYY-MM-DD HH:mm:ss');
        }
    },

    timeFormat: function(time) {
        if (time !== null && time !== '') {
            let date = new Date(time);
            return moment(date).format('YYYY-MM-DD HH:mm:ss');
        }
    },

    dateFormat: function(dateStr) {
        if (dateStr !== null && dateStr !== '') {
            let date = new Date(dateStr);
            return moment(date).format('YYYY-MM-DD');
        }
    }

}

export default func;